<?php

namespace app\admin\validate;

use think\Validate;

class Column extends Validate
{
    protected $rule = [
        'name' => 'require|max:45|chsDash|unique:column',
        'name_en' => 'max:45|alpha|unique:column',
        'sort' => 'number'
    ];
    protected $message = [
        'name.require' => '栏目名必须填写',
        'name.max' => '栏目名最大长度为45个字符',
        'name.chsDash' => '栏目名只能由汉字、字母、数字和下划线_及破折号-组成',
        'name_en.alpha' => '栏目英文名只能由字母组成',
        'name_en.max' => '栏目英文名最大长度为45个字符',
        'name_en.unique' => '栏目英文名已经存在',
        'name.unique' => '该栏目名已经存在',
        'sort.number' => '排序只能为数字',
    ];
    protected $scene = [
        'create' => [],
        'update' => [],
        'cellEdit' => ['name'=>'max:45|chsDash|unique:column','sort', 'name_en']
    ];
}